package com.gzy.rpsm_property.pojo;


import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel
public class ResponsePojo<T> {
    @ApiModelProperty(value = "响应的数据")
    private T data;
    @ApiModelProperty("响应的说明信息")
    private String message;
    @ApiModelProperty("响应状态码，1：成功，2：失败")
    private int code; //成功为 1，失败为 2

    private ResponsePojo(T t) {
        this.data = t;
        this.message = "";
        this.code = 1;//成功1 失败2
    }




    public ResponsePojo() {
    }

    public ResponsePojo(T data, String message, int code) {
        this.data = data;
        this.message = message;
        this.code = code;
    }

    /**
     * 获取
     *
     * @return data
     */
    public T getData() {
        return data;
    }

    /**
     * 设置
     *
     * @param data
     */
    public void setData(T data) {
        this.data = data;
    }

    /**
     * 获取
     *
     * @return message
     */
    public String getMessage() {
        return message;
    }

    /**
     * 设置
     *
     * @param message
     */
    public void setMessage(String message) {
        this.message = message;
    }

    /**
     * 获取
     *
     * @return code
     */
    public int getCode() {
        return code;
    }

    /**
     * 设置
     *
     * @param code
     */
    public void setCode(int code) {
        this.code = code;
    }
    public static <T>ResponsePojo<T> success(T t){
        return new ResponsePojo(t);
    }
    public static <T>ResponsePojo<T> fail(T t,String message){return new ResponsePojo(t,message,2);
    }
    public String toString() {
        return "ResponsePojo{data = " + data + ", message = " + message + ", code = " + code + "}";
    }
}

